<div fNodeInput [fInputId]="node().key" fInputConnectableSide="top" class="top"></div>

@if (status() === 'template') {
  <i class="ri-spam-2-line absolute right-3 top-3 text-xl leading-5 text-orange-500" 
    [matTooltip]="'PAC.Xpert.NeedReconfigure' | translate: {Default: 'Need to reconfigure'}"
  ></i>
}

<div class="max-w-full flex justify-start items-center px-3 pt-3 pb-2">
  <emoji-avatar [avatar]="toolset().avatar" small class="shrink-0 mr-2 rounded-lg overflow-hidden shadow-sm" />
  <div class="truncate">
    {{toolset().name}}
  </div>
</div>

<div class="max-w-full max-h-14 px-4 text-text-tertiary text-sm text-left line-clamp-2"
  [title]="toolset().description">{{toolset().description}}</div>

<div class="w-full flex flex-col justify-start items-stretch p-2 gap-1 max-h-48 overflow-y-auto"
  (wheel)="$event.stopPropagation()"
>
  @for (item of tools(); track item.tool.id) {
    <div class="relative flex items-center gap-1 px-4 py-2 text-left rounded-lg text-sm bg-gray-100 dark:bg-zinc-800"
      [matTooltip]="item.tool.description"
      matTooltipPosition="after"
    >
      @for (execution of item.executions; track execution) {
        @switch (execution.status) {
          @case (eXpertAgentExecutionEnum.RUNNING) {
            <ngm-spin class="shrink-0 scale-90 origin-center" small />
          }
          @case (eXpertAgentExecutionEnum.ERROR) {
            <div class="w-2 h-2 shrink-0 border border-solid rounded-[3px] bg-red-500 border-red-600 shadow-[0_0_5px_-3px_rgba(14,159,110,0.1),0.5px_0.5px_3px_rgba(14,159,110,0.3),inset_1.5px_1.5px_0px_rgba(255,255,255,0.2)]"
              [matTooltip]="execution.error"
              matTooltipPosition="above"
            ></div>
          }
          @case (eXpertAgentExecutionEnum.SUCCESS) {
            <div class="w-2 h-2 shrink-0 border border-solid rounded-[3px] bg-[#31C48D] border-[#0E9F6E] shadow-[0_0_5px_-3px_rgba(14,159,110,0.1),0.5px_0.5px_3px_rgba(14,159,110,0.3),inset_1.5px_1.5px_0px_rgba(255,255,255,0.2)]"
              [matTooltip]="execution.outputs?.output"
              matTooltipPosition="above"
            >
            </div>
          }
        }
      }
      
      @if (isSensitive(item.tool.name)) {
        <i class="ri-shield-keyhole-line shrink-0 text-lg leading-4 text-text-warning"
          [matTooltip]="'PAC.Xpert.SensitiveToolsTip' | translate: {Default: 'Sensitive tools require user confirmation before execution'}"
          matTooltipPosition="above"></i>
      }
      <span class="flex-1 truncate" [title]="item.tool.description || item.tool.name">
        {{item.tool.name}}
      </span>

      @if (hasMemory(item.tool.name)) {
        <i class="ri-brain-fill shrink-0 text-lg leading-4 text-text-secondary"
          [matTooltip]="'PAC.Xpert.ToolMemoryTip' | translate: {Default: 'Tool memory, storing tool results in agent state variables'}"
          matTooltipPosition="above"></i>
      }
      @if (isEnd(item.tool.name)) {
        <i class="ri-stop-circle-line shrink-0 text-lg leading-4 text-text-secondary"
          [matTooltip]="'PAC.Xpert.EndTool' | translate: {Default: 'Terminal tool, the run of chat ends when tool completed'}"
          matTooltipPosition="above"></i>
      }
    </div>
  }
</div>